<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:68:"D:\phpStudy\WWW\oa\public/../application/index\view\apply\index.html";i:1515483585;}*/ ?>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <meta name="renderer" content="webkit">
    <title>添加内容</title>
    <link rel="stylesheet" href="__CSS__/pintuer.css">
    <link rel="stylesheet" href="__CSS__/admin.css">
    <link rel="stylesheet" href="__STATIC__/css/layui.css">
    <script src="__STATIC__/layui.js"></script>
    <script src="__JS__/jquery.js"></script>
    <script src="__JS__/pintuer.js"></script>
</head>
<style>
    /*table {width: 640px;height: 360px; margin: auto;margin-top: 2%}
    td {border:1px solid black;vertical-align: middle;text-align: center}
    th {border:1px solid black;vertical-align: middle;text-align: center}*/
</style>
<body>
<div class="panel admin-panel">
    <div class="panel-head"><strong class="icon-reorder">费用报销申请</strong>&emsp;<a
            style="color: #3a4bfb;font-weight: bold " href="javascript:history.go(-1)">返回上一步</a></div>
    <div class="layui-tab layui-tab-card" style="width: 1100px;margin-top: auto;">
        <ul class="layui-tab-title">
            <li class="layui-this">费用报销申请</li>
            <li>付款申请</li>
            <li>考勤签到申请</li>
            <li>请假申请</li>
            <li>福利申请</li>
            <li>出差申请</li>
            <li>接待费用申请</li>
            <li>合同申请</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form" id="form">
                    <div class="layui-form-item">
                        <div style=" margin-left: 3%" class="layui-inline">
                            <lable style="float: left;margin-top: 3%" class="layui-form-lable">
                                审批流程：
                            </lable>
                            <div class="layui-input-inline">
                                <select id="flow_id" name="flow_id">
                                    <?php if(is_array($flow_reimbursement_apply) || $flow_reimbursement_apply instanceof \think\Collection || $flow_reimbursement_apply instanceof \think\Paginator): $i = 0; $__LIST__ = $flow_reimbursement_apply;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $vo['id']; ?>"><?php echo $vo['flow']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <lable style="float: left;margin-top: 3%" class="layui-form-lable">
                                时间：
                            </lable>
                            <div style="" class="layui-input-inline">
                                <input type="hidden" value="1" name="bill_type_id" id="bill_type_id">
                                <input type="text" readonly="readonly" id="reimbursement_time"
                                       lay-verify="date|required" placeholder="yyyy-MM-dd"
                                       name="reimbursement_time" class="layui-input">
                            </div>
                        </div>
                        <div style="margin-top: 3%;margin-left: 3%" class="layui-upload-drag" id="test10">
                            <i class="layui-icon"></i>
                            <p>点击上传，或将文件拖拽到此处</p>
                            <p><b style="color: red">警告！</b>请在提交报销费用前上传，否则文件无效</p>
                        </div>
                    </div>
                    <h3 style="text-align: center;margin-top: 4%"><b>费用报销单</b></h3>
                    <table style="margin-top: 3%" class="layui-table" lay-size="lg">
                        <col width="350">
                        <col width="150">
                        <thead>
                        <tr>
                            <th style="text-align: center">用途</th>
                            <th style="text-align: center">金额（元）</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr>
                            <td><input name="purpose_a" id="purpose_a" type="text" class="layui-input"></td>
                            <td><input onblur="sum('money_a')" lay-verify="num" id="money_a" name="money_a" type="text"
                                       class="layui-input"></td>
                        </tr>
                        <tr>
                            <td><input name="purpose_b" id="purpose_b" type="text" class="layui-input"></td>
                            <td><input onblur="sum('money_b')" lay-verify="num" id="money_b" name="money_b" type="text"
                                       class="layui-input"></td>
                        </tr>
                        <tr>
                            <td><input name="purpose_c" id="purpose_c" type="text" class="layui-input"></td>
                            <td><input onblur="sum('money_c')" lay-verify="num" id="money_c" name="money_c" type="text"
                                       class="layui-input"></td>
                        </tr>
                        <tr>
                            <td><input name="purpose_d" id="purpose_d" type="text" class="layui-input"></td>
                            <td><input onblur="sum('money_d')" lay-verify="num" id="money_d" name="money_d" type="text"
                                       class="layui-input"></td>
                        </tr>
                        <tr>
                            <td><input name="purpose_e" type="text" class="layui-input"></td>
                            <td><input onblur="sum('money_e')" lay-verify="num" id="money_e" name="money_e" type="text"
                                       class="layui-input"></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">合计</td>
                            <td><input readonly="readonly" lay-verify="num" id="total" name="total" type="text"
                                       class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left;" colspan="2">大写金额：<input id="capital_total"
                                                                                  name="capital_total" type="text"
                                                                                  class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: left">原借款：<input lay-verify="num" id="original_borrow"
                                                                    name="original_borrow"
                                                                    type="text"
                                                                    class="layui-input"></td>
                            <td style="text-align: left">退/补：<input lay-verify="num" id="return" name="return"
                                                                    type="text"
                                                                    class="layui-input"></td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="layui-form-item">
                        <div style="float: right;margin-top: 2%;margin-right: 10%" class="layui-input-block">
                            <button id="upload_expense_reimbursement" class="layui-btn" lay-submit="" lay-filter="demo">
                                立即提交
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item">
                <form class="layui-form">
                    <h3 style="text-align: center;margin-top: 3%"><b>付款申请表</b></h3>
                    <input type="hidden" value="2" name="bill_type_id">
                    <div style=" margin-left: 3%" class="layui-inline">
                        <lable style="float: left;margin-top: 3%" class="layui-form-lable">
                            审批流程：
                        </lable>
                        <div class="layui-input-inline">
                            <select id="payment_application_form_flow_id" name="payment_application_form_flow_id">
                                <?php if(is_array($flow_payment_application_form) || $flow_payment_application_form instanceof \think\Collection || $flow_payment_application_form instanceof \think\Paginator): $i = 0; $__LIST__ = $flow_payment_application_form;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo['id']; ?>"><?php echo $vo['flow']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <table style="margin-top: 2%    " class="layui-table" lay-size="lg">
                        <colgroup>
                            <col width="100">
                            <col width="180">
                            <col width="150">
                            <col width="150">
                        </colgroup>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">付款事由：</td>
                            <td colspan="3"><input type="text" lay-verify="required" class="layui-input"
                                                   name="account_payment"></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">收款单位：</td>
                            <td><input type="text" lay-verify="required" class="layui-input" name="payee"></td>
                            <td style="text-align: center;vertical-align: middle">申请时间：</td>
                            <td><input readonly="readonly" type="text" lay-verify="date|required"
                                       placeholder="yyyy-MM-dd" class="layui-input" id="payment_application_form_time"
                                       name="payment_application_form_time"></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">银行账号：</td>
                            <td><input type="text" class="layui-input" lay-verify="num|required" name="bank_account">
                            </td>
                            <td style="text-align: center;vertical-align: middle">开户银行：</td>
                            <td><input type="text" class="layui-input" lay-verify="required"
                                       name="account_opening_bank"></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">付款金额：</td>
                            <td colspan="3"><input type="text" lay-verify="num|required" class="layui-input"
                                                   name="amount_payment"></td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">付款方式：</td>
                            <td colspan="2" style="text-align: center;vertical-align: middle"><input
                                    name="payment_method" value="票汇" title="票汇" checked="" type="radio"><input
                                    name="payment_method" value="信汇" title="信汇" checked="" type="radio"><input
                                    name="payment_method" value="电汇" title="电汇" checked="" type="radio"><input
                                    name="payment_method" value="现金" title="现金" checked="" type="radio"></td>
                            <td>转账号码：<input type="text" lay-verify="num" class="layui-input"
                                            name="tranfser_number"></td>
                        </tr>
                    </table>
                    <div class="layui-form-item">
                        <div style="float: right;margin-top: 2%;margin-right: 10%" class="layui-input-block">
                            <button id="upload_payment_application_form" class="layui-btn" lay-submit=""
                                    lay-filter="demo">立即提交
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">
                <form class="layui-form">
                    <h3 style="text-align: center;margin-top: 2%;margin-bottom: 2%"><b>请假申请表</b></h3>
                    <div class="layui-inline">
                        <lable style="float: left;margin-top: 3%" class="layui-form-lable">
                            请假类型：
                        </lable>
                        <div class="layui-input-inline">
                            <select id="type_leave" name="type_leave" lay-search="">
                                <?php if(is_array($leave) || $leave instanceof \think\Collection || $leave instanceof \think\Paginator): $i = 0; $__LIST__ = $leave;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo['type_leave']; ?>"><?php echo $vo['type_leave']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <input type="hidden" value="4" name="bill_type_id">
                    <div style=" margin-left: 3%" class="layui-inline">
                        <lable style="float: left;margin-top: 3%" class="layui-form-lable">
                            审批流程：
                        </lable>
                        <div class="layui-input-inline">
                            <select id="leave_flow_id" name="leave_flow_id">
                                <?php if(is_array($flow_leave) || $flow_leave instanceof \think\Collection || $flow_leave instanceof \think\Paginator): $i = 0; $__LIST__ = $flow_leave;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                <option value="<?php echo $vo['id']; ?>"><?php echo $vo['flow']; ?></option>
                                <?php endforeach; endif; else: echo "" ;endif; ?>
                            </select>
                        </div>
                    </div>
                    <table style="margin-top: 2%    " class="layui-table" lay-size="lg">
                        <colgroup>
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="100">
                            <col width="150">
                            <col width="150">
                        </colgroup>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">姓名：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <?php echo $myself_list['ch_name']; ?>
                            </td>
                            <td style="text-align: center;vertical-align: middle">部门：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <?php echo $myself_list['branch']; ?>
                            </td>
                            <td style="text-align: center;vertical-align: middle">岗位/职务：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <?php echo $myself_list['position']; ?>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="text-align: center;vertical-align: middle">
                                <div style="margin-left: 0" class="layui-input-block">
                                    <textarea name="off" placeholder="调休必须到考勤管理部门核对有效的加班时间，并列出抵充时间。"
                                              class="layui-textarea"></textarea>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="text-align: center;vertical-align: middle">
                                <div style="margin-left: 0" class="layui-input-block">
                                    <textarea name="leave_ask" placeholder="请假补充说明：" class="layui-textarea"></textarea>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="text-align: center;vertical-align: middle">
                                <div style="margin-left: 0" class="layui-input-block">
                                    <textarea name="job_agent" placeholder="职务代理人（三天以上的假期必须填写）："
                                              class="layui-textarea"></textarea>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="6" style="text-align: center;vertical-align: middle">
                                <div style="margin-left: 0" class="layui-input-block">
                                    <textarea name="handover" placeholder="有无工作交接情况，如有请列出交接事宜（三天以上的假期必须填写）："
                                              class="layui-textarea"></textarea>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">请假时间：</td>
                            <td colspan="3">
                                <input class="layui-input" lay-verify="required" name="leave_time" id="leave_time"
                                       placeholder="开始 到 结束" type="text">
                            </td>
                            <td style="text-align: center;vertical-align: middle">申请时间：</td>
                            <td><input class="layui-input" lay-verify="date|required" placeholder="yyyy-MM-dd"
                                       name="leave_form_time" id="leave_form_time" type="text"></td>
                        </tr>
                    </table>
                    <div class="layui-form-item">
                        <div style="float: right;margin-top: 2%;margin-right: 10%" class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="demo">立即提交</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">暂未开通此功能</div>
            <div class="layui-tab-item">
                <form class="layui-form" method="post" enctype="multipart/form-data">
                    <h3 style="text-align: center;margin-top: 3%"><b>合同申请表</b></h3>
                    <input type="hidden" value="8" name="bill_type_id">
                       <div style="margin-top: 2%" class="layui-form-item">
                            <div class="layui-inline">
                                <label style="float: left;margin-top: 3%" class="layui-form-lable">合同流程：</label>
                                <div style="float:left;" class="layui-inline-input">
                                    <select name="contract_flow_id" id="contract_flow_id">
                                        <?php if(is_array($flow_contract_form) || $flow_contract_form instanceof \think\Collection || $flow_contract_form instanceof \think\Paginator): $i = 0; $__LIST__ = $flow_contract_form;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vo): $mod = ($i % 2 );++$i;?>
                                        <option value="<?php echo $vo['id']; ?>"><?php echo $vo['flow']; ?></option>
                                        <?php endforeach; endif; else: echo "" ;endif; ?>
                                    </select>
                                </div>
                            </div>
                           <div class="layui-inline">
                               <label style="float: left;margin-top: 3%" class="layui-form-lable">申请时间：</label>
                               <div style="float:left;"  class="layui-inline-input">
                                   <input id="contract_approve_time" name="contract_approve_time" class="layui-input" type="text" lay-verify="date|required" placeholder="yyyy-MM-dd">
                               </div>
                           </div>
                        </div>
                    <table class="layui-table" lay-size="lg">
                        <colgroup>
                            <col width="150">
                            <col width="150">
                            <col width="150">
                            <col width="150">
                        </colgroup>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">提交区域：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <select lay-verify="required" name="sub_region" lay-search="">
                                    <?php if(is_array($contract_region) || $contract_region instanceof \think\Collection || $contract_region instanceof \think\Paginator): $i = 0; $__LIST__ = $contract_region;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$re): $mod = ($i % 2 );++$i;if($re['id'] == $myself_list['region_id']): ?>
                                    <option selected="selected" value="<?php echo $re['id']; ?>"><?php echo $re['region']; ?></option>
                                    <?php else: ?>
                                    <option value="<?php echo $re['id']; ?>"><?php echo $re['region']; ?></option>
                                    <?php endif; endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </td>
                            <td style="text-align: center;vertical-align: middle">合同类别：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <select name="contract_type" lay-search="" lay-verify="required">
                                    <?php if(is_array($contract_type) || $contract_type instanceof \think\Collection || $contract_type instanceof \think\Paginator): $i = 0; $__LIST__ = $contract_type;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$ty): $mod = ($i % 2 );++$i;?>
                                    <option value="<?php echo $ty['id']; ?>"><?php echo $ty['contract_type']; ?></option>
                                    <?php endforeach; endif; else: echo "" ;endif; ?>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">合同名称：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <input name="contract_name" lay-verify="required" id="contract_name" type="text" class="layui-input">
                            </td>
                            <td style="text-align: center;vertical-align: middle">合同编号：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <input name="contract_code" lay-verify="required" id="contract_code" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">合同对方：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <input name="contract_party" lay-verify="required" id="contract_party" type="text" class="layui-input">
                            </td>
                            <td style="text-align: center;vertical-align: middle">合同签订时间：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <input class="layui-input" lay-verify="date|required" placeholder="yyyy-MM-dd"
                                       name="contract_time" id="contract_time" type="text">
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">合同暂定价：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <input name="contract_temporary_price" id="contract_temporary_price" type="text" class="layui-input">
                            </td>
                            <td style="text-align: center;vertical-align: middle">合同结算价：</td>
                            <td style="text-align: center;vertical-align: middle">
                                <input name="contract_settlement_price" id="contract_settlement_price" type="text" class="layui-input">
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">合同描述：</td>
                            <td colspan="3" style="text-align: center;vertical-align: middle">
                                <div style="margin-left: 0" class="layui-input-block">
                                    <textarea name="contract_description" placeholder=""
                                              class="layui-textarea"></textarea>
                                </div>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: center;vertical-align: middle">付款进度：</td>
                            <td colspan="3" style="text-align: center;vertical-align: middle">
                                <div style="margin-left: 0" class="layui-input-block">
                                    <textarea name="contract_payment_progress" placeholder=""
                                              class="layui-textarea"></textarea>
                                </div>
                            </td>
                        </tr>
                    </table>

                    <div class="layui-upload">
                        <button type="button" class="layui-btn layui-btn-normal" id="testList">上传相关文件</button>
                        <div class="layui-upload-list">
                            <table class="layui-table">
                                <thead>
                                <tr><th>文件名</th>
                                    <th>大小</th>
                                    <th>状态</th>
                                    <th>操作</th>
                                </tr></thead>
                                <tbody id="demoList"></tbody>
                            </table>
                        </div>
                        <button type="button" class="layui-btn" id="upload_contract_form">开始上传</button>
                    </div>
                    <div class="layui-form-item">
                        <div style="float: right;margin-top: 2%;margin-right: 10%" class="layui-input-block">
                            <button class="layui-btn" lay-submit="" lay-filter="demo_contract">
                                立即提交
                            </button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>

        </div>
    </div>
</div>
</body>
<script>
    function sum() {
        var verity = /^\d+(\.\d+)?$/;
        var money_a = $('#money_a').val();
        var money_b = $('#money_b').val();
        var money_c = $('#money_c').val();
        var money_d = $('#money_d').val();
        var money_e = $('#money_e').val();
        if (money_a == '') {
            money_a = 0;
        } else {
            money_a = parseFloat(money_a);
            if (money_a != '') {
                if (!verity.test(money_a)) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.tips('Hi，请输入数字', '#money_a');
                    });
                }
            }
        }
        if (money_b == '') {
            money_b = 0;
        } else {
            money_b = parseFloat(money_b);
            if (money_b != '') {
                if (!verity.test(money_b)) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.tips('Hi，请输入数字', '#money_b');
                    })
                }
            }
        }
        if (money_c == '') {
            money_c = 0;
        } else {
            money_c = parseFloat(money_c);
            if (money_c != '') {
                if (!verity.test(money_c)) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.tips('Hi，请输入数字', '#money_c');
                    });
                }
            }
        }
        if (money_d == '') {
            money_d = 0;
        } else {
            money_d = parseFloat(money_d);
            if (money_d != '') {
                if (!verity.test(money_d)) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.tips('Hi，请输入数字', '#money_d');
                    });
                }
            }
        }
        if (money_e == '') {
            money_e = 0;
        } else {
            money_e = parseFloat(money_e);
            if (money_e != '') {
                if (!verity.test(money_e)) {
                    layui.use(['layer'], function () {
                        var layer = layui.layer;
                        layer.tips('Hi，请输入数字', '#money_e');
                    });
                }
            }
        }

        var sums = money_a + money_b + money_c + money_d + money_e;
        $('#total').val(sums)
    }
    layui.use('element', function () {
        var $ = layui.jquery
            , element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块

        //触发事件
        var active = {
            tabAdd: function () {
                //新增一个Tab项
                element.tabAdd('demo', {
                    title: '新选项' + (Math.random() * 1000 | 0) //用于演示
                    , content: '内容' + (Math.random() * 1000 | 0)
                    , id: new Date().getTime() //实际使用一般是规定好的id，这里以时间戳模拟下
                })
            }

        };

        $('.site-demo-active').on('click', function () {
            var othis = $(this), type = othis.data('type');
            active[type] ? active[type].call(this, othis) : '';
        });

        //Hash地址的定位
        var layid = location.hash.replace(/^#test=/, '');
        element.tabChange('test', layid);

        element.on('tab(test)', function (elem) {
            location.hash = 'test=' + $(this).attr('lay-id');
        });

    });
</script>
<script>
    layui.use(['form', 'layer', 'laydate'], function () {
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate;

        //日期时间范围
        laydate.render({
            elem: '#leave_time'
            , type: 'datetime'
            , range: true
        });
        //日期
        laydate.render({
            elem: '#reimbursement_time'
        });
        //合同申请日期
        laydate.render({
            elem: '#contract_approve_time'
        });
        //合同签订日期
        laydate.render({
            elem: '#contract_time'
        });
        laydate.render({
            elem: '#payment_application_form_time'
        });
        laydate.render({
            elem: '#leave_form_time'
        });
        //自定义验证规则
        form.verify({
            num: [/^[0-9]+(.[0-9]{2})?$/, '金额只能为数字']

        });
        //监听提交
        form.on('submit(demo)', function (data) {
            var datas = JSON.stringify(data.field);
            //console.log(datas);
            var sub = 'submit';
            $.ajax({
                type: "post",
                url: "<?php echo url('Apply/apply'); ?>",
                data: {"data": datas, 'sub': sub},
                dataType: "json",
                success: function (a) {
                    //console.log(a);
                    if (a > 0) {
                        layer.msg('添加成功', {icon: 1});
                        //window.setTimeout("window.location=\"<?php echo url('Myself/myselfapprove'); ?>\"", 2000);
                        window.location.href = "<?php echo url('Myself/myselfapprove'); ?>"
                        //layer.close(index);
                    } else {
                        layer.msg('添加失败', {icon: 2});
                        //layer.close(index);
                    }
                    setTimeout(function () {
                        //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                        window.location.reload();//页面刷新
                    }, 2000);
                }

            });
            return false;
        });
        //监听合同提交
        form.on('submit(demo_contract)', function (data) {
            var datas = JSON.stringify(data.field);
            //console.log(datas);
            var sub = 'submit';
            $.ajax({
                type: "post",
                url: "<?php echo url('Apply/apply'); ?>",
                data: {"data": datas, 'sub': sub},
                dataType: "json",
                success: function (a) {
                    //console.log(a);
                    if (a > 0) {
                        layer.msg('添加成功', {icon: 1});
                        //window.setTimeout("window.location=\"<?php echo url('Myself/myselfapprove'); ?>\"", 2000);
                        //window.location.href = "<?php echo url('Myself/myselfapprove'); ?>"
                        //layer.close(index);
                    } else {
                        layer.msg('添加失败', {icon: 2});
                        setTimeout(function () {
                            //使用  setTimeout（）方法设定定时2000<a href="https://www.baidu.com/s?wd=%E6%AF%AB%E7%A7%92&tn=44039180_cpr&fenlei=mv6quAkxTZn0IZRqIHckPjm4nH00T1dWuHn4n1DkmynYmhu9uhcd0ZwV5Hcvrjm3rH6sPfKWUMw85HfYnjn4nH6sgvPsT6KdThsqpZwYTjCEQLGCpyw9Uz4Bmy-bIi4WUvYETgN-TLwGUv3EnHf4PWmsrHRdnWckPWnkrHmkrf" target="_blank" class="baidu-highlight">毫秒</a>
                            window.location.reload();//页面刷新
                        }, 2000);
                        //layer.close(index);
                    }

                }

            });
            return false;
        });

    });
</script>
<script>
    layui.use('upload', function () {
        var $ = layui.jquery
            , upload = layui.upload
            , layer = layui.layer;

        //多文件列表示例
        var demoListView = $('#demoList')
            ,uploadListIns = upload.render({
            elem: '#testList'
            ,url: "<?php echo url('Apply/uploads'); ?>"
            ,accept: 'file'
            ,multiple: true
            ,auto: false
            ,bindAction: '#upload_contract_form'
            ,choose: function(obj){
                var files = this.files = obj.pushFile(); //将每次选择的文件追加到文件队列
                //读取本地文件
                obj.preview(function(index, file, result){
                    var tr = $(['<tr id="upload-'+ index +'">'
                        ,'<td>'+ file.name +'</td>'
                        ,'<td>'+ (file.size/1014).toFixed(1) +'kb</td>'
                        ,'<td>等待上传</td>'
                        ,'<td>'
                        ,'<button class="layui-btn layui-btn-mini demo-reload layui-hide">重传</button>'
                        ,'<button class="layui-btn layui-btn-mini layui-btn-danger demo-delete">删除</button>'
                        ,'</td>'
                        ,'</tr>'].join(''));

                    //单个重传
                    tr.find('.demo-reload').on('click', function(){
                        obj.upload(index, file);
                    });

                    //删除
                    tr.find('.demo-delete').on('click', function(){
                        delete files[index]; //删除对应的文件
                        tr.remove();
                        uploadListIns.config.elem.next()[0].value = ''; //清空 input file 值，以免删除后出现同名文件不可选
                    });

                    demoListView.append(tr);
                });
            }
            ,done: function(res, index, upload){
                //console.log(res);
                if(res.code == 0){ //上传成功
                    var tr = demoListView.find('tr#upload-'+ index)
                        ,tds = tr.children();
                    tds.eq(2).html('<span style="color: #5FB878;">'+res.msg+'</span>');
                    tds.eq(3).html(''); //清空操作
                    return delete this.files[index]; //删除文件队列已经上传成功的文件
                }
                this.error(index, upload);
            }
            ,error: function(index, upload){
                var tr = demoListView.find('tr#upload-'+ index)
                    ,tds = tr.children();
                tds.eq(2).html('<span style="color: #FF5722;">上传失败</span>');
                tds.eq(3).find('.demo-reload').removeClass('layui-hide'); //显示重传
            }
        });
        //拖拽上传
        upload.render({
            elem: '#test10'
            , accept: 'file'
            , url: "<?php echo url('Apply/upload'); ?>"
            , auto: false
            , bindAction: '#upload_expense_reimbursement'
            , done: function (res) {
                if (res.code == 0) { //上传成功
                    layer.msg('上传成功', {icon: 1})
                }
                else if (res.code == 1) { //上传成功
                    layer.msg('上传失败', {icon: 2})
                }
            }
        });
    });
</script>
</html>